#include<bits/stdc++.h>
using namespace std;

class Solution {
public:
    int firstBadVersion(int n) {
        int low = 1, high = n, mid;
        while(low < high){
            mid = low + (high - low) / 2; // 这样写二分可以避免溢出
            if(!isBadVersion(mid))low = mid + 1;
            else high = mid;
        }
        return low;
    }
};

/**
 * @brief 2022.3.1
 * 经典二分
 */
